﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EBA.Dynamic;

namespace EBA.Tests.Dynamic
{
    [TestClass]
    public class MultiInterfaceInheritanceTest
    {
        [TestMethod]
        public void support_multi_interface_inheritances()
        {
            var obj = new MyClass();
            obj.Name = "Parent";
            obj.ChildName = "Child";

            var child = obj.DynamicCastTo<IChild>();

            Assert.AreEqual("Parent", child.Name);
            Assert.AreEqual("Child", child.ChildName);

            Assert.AreEqual("Parent", child.Invoke());
            Assert.AreEqual("Child", child.InvokeChild());
        }

        #region Helpers



        public interface IParent
        {
            string Name { get; set; }
            string Invoke();
        }

        public interface IChild : IParent
        {
            string ChildName { get; set; }
            string InvokeChild();
        } 


        public class MyClass{
            public string Name { get; set; }
            public string ChildName { get; set; }
            public string Invoke()
            {
                return this.Name;
            }
            public string InvokeChild()
            {
                return this.ChildName;
            }
        }
        #endregion

    }
}
